﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UserControlLib.Models;

namespace UserControlLib.Actions
{
    public class PageBarAction
    {
        public static bool GetDataByPage<T>(int pageSize, int pageIndex, List<T> list, T obj) where T : DataModel
        {
            var temp = list.FirstOrDefault(t => t.Key == obj.Key);
            if (temp == null) return false;
            int index = list.IndexOf(temp);
            if (index >= pageSize * (pageIndex - 1) && index < pageSize * pageIndex)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
